package com.blog.effective.note8;

import java.awt.*;

/**
 * 〈一个带有颜色的点〉<br>
 *
 * @author 未绪
 * @time 2017/12/17 11:52
 */
public class ColorPoint {

    //给改点新增加一个颜色元素
    private Color color;
    private Point point;

    public ColorPoint(int x, int y, Color color) {
        point=new Point(x,y);
        this.color = color;
    }
    @Override
    public boolean equals(Object obj) {
        if (obj instanceof ColorPoint) {
            ColorPoint cp = (ColorPoint) obj;
            return cp.point.equals(obj) && this.color == cp.color;
        }
        return false;
    }
//    public ColorPoint(int x, int y, Color color) {
//        super(x, y);
//        this.color = color;
//    }

//    @Override
//    public boolean equals(Object obj) {
//        if (obj instanceof ColorPoint) {
//            ColorPoint cp = (ColorPoint) obj;
//            return super.equals(obj) && this.color == cp.color;
//        }
//        return false;
//    }
//
//    @Override
//    public boolean equals(Object obj) {
//
//        if(obj instanceof ColorPoint){
//            // 非混合比较
//            ColorPoint cp = (ColorPoint) obj;
//            return super.equals(obj) && this.color == cp.color;
//        }
//
//        if (obj instanceof Point) {
//            //混合比较
//            return obj.equals(this);
//        }
//
//        return false;
//    }

}
